<?php
/**
 * Created by PhpStorm.
 * User: junying.wei
 * Date: 17/11/05
 * Time: 下午2:09
 */
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../../AopSdk.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../entites/ApiParamModel.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../entites/ApiInfoModel.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'../model/result/AlipayTradeAppPayResult.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'../model/builder/AlipayTradeAppPayContentBuilder.php';
require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../config/DefaultAlipayClientFactory.php';

$req = new AlipayTradeAppPayContentBuilder();

$req->setTimeoutExpress($_POST['timeoutExpress']);
    $req->setTotalAmount($_POST['totalAmount']);
    $req->setSellerId($_POST['sellerId']);
    $req->setProductCode($_POST['productCode']);
    $req->setBody($_POST['body']);
    $req->setSubject($_POST['subject']);
    $req->setOutTradeNo($_POST['outTradeNo']);
    $req->setTimeExpire($_POST['timeExpire']);
    $req->setGoodsType($_POST['goodsType']);
    $req->setPromoParams($_POST['promoParams']);
    $req->setPassbackParams($_POST['passbackParams']);
    $req->setRoyaltyInfo($_POST['royaltyInfo']);
    $req->setExtendParams($_POST['extendParams']);
    $req->setSubMerchant($_POST['subMerchant']);
    $req->setQuantity($_POST['quantity']);
    $req->setEnablePayChannels($_POST['enablePayChannels']);
    $req->setStoreId($_POST['storeId']);
    $req->setSpecifiedChannel($_POST['specifiedChannel']);
    $req->setDisablePayChannels($_POST['disablePayChannels']);
    $req->setSettleInfo($_POST['settleInfo']);
    $req->setInvoiceInfo($_POST['invoiceInfo']);
    $req->setExtUserInfo($_POST['extUserInfo']);
    $req->setBusinessParams($_POST['businessParams']);
    
    $request = new AlipayTradeAppPayRequest();
	$request->setBizContent ( $req->getBizContent() );
	
    $ext= new DefaultAlipayClientFactory(); 
	//因为是页面跳转类服务，使用pageExecute方法得到form表单后输出给前端跳转
	$response = $ext->aopclientRequestExecute ( $request, "POST");
    echo json_encode($response);
?>